package com.zxx.pattern.factoryPattern.factoryFunc;

import com.zxx.pattern.factoryPattern.factorySample.BMW;

import java.util.Scanner;

/**
 * @author zxx on 2020/12/28
 */
public class Test {

    private static BMW bmw;
    private static FactoryBMW factory;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请选择要生产的汽车的型号：");
        System.out.println("1、BMW 523");
        System.out.println("2、BMW 320");
        int type = scanner.nextInt();

        switch (type) {
            case 1:
                factory = new FactoryBMW523();
                break;
            case 2:
                factory = new FactoryBMW320();
                break;
            default:
                factory = null;
                break;
        }
        if (factory != null) {
            bmw = factory.createBMW();
            bmw.introduce();
        } else {
            System.out.println("没有这个车型！");
        }
        scanner.close();
    }

}
